#include "friendlistitem.h"
#include "ui_friendlistitem.h"
#include <QMouseEvent>

FriendListItem::FriendListItem(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::FriendListItem)
{
    ui->setupUi(this);
}

FriendListItem::~FriendListItem()
{
    delete ui;
}

//// 设置Item
void FriendListItem::SetItem(int Item)
{
    m_Item = Item;
}

//// 取Item
int  FriendListItem::GetItem()
{
    return m_Item;
}


//// 鼠标点击事件
void FriendListItem::mousePressEvent(QMouseEvent *event)
{
    if (event->button() == Qt::LeftButton)
    {
        emit SignalThisItemClicked(ui->lb_FriendsName->text(),m_nId);
//        this->setStyleSheet("");
    }

}




void FriendListItem::SetId(QString Id)
{
    m_nId = Id;
}

QString  FriendListItem::GetId()
{
    return m_nId;
}

//// 为该项设置内容
void FriendListItem::updateItemInfo(QVector<QString> UserOrderFormList,char i)
{

//    FriendsList.value(0);///好友头像
//    FriendsList.value(1);///好友昵称（备注）
////    FriendsList.value(2);///最近一条聊天记录        ////未实现
//    FriendsList.value(2);///是否加入黑名单
//    FriendsList.value(3);///好友账号

      QString HeadPicture = "../Phone_platform/sources/head/" + UserOrderFormList.value(0+i*4) + ".jpg";
      QImage img(HeadPicture);
      ui->lb_HeadPhoto->setPixmap(QPixmap::fromImage(img));
      ui->lb_FriendsName->setText(UserOrderFormList.value(1+i*4));
      ui->lb_ChatRecodes->setText(UserOrderFormList.value(2+i*4));
      m_nId = UserOrderFormList.value(3+i*4);
}
